import java.util.ArrayList;
import java.util.List;



public class Anagrams {
	public void tester() {
		String [] a = {"","",""};
		anagrams(a);
	}
    public List<String> anagrams(String[] strs) {
    	int [] h = new int [strs.length];

        List <String> strRe = new ArrayList <String>();
        List <Integer> intRe = new ArrayList <Integer>();
        
        for(int i =0 ; i < strs.length ; i++) {
            h[i] = hash(strs[i]);
//            System.out.println(h[i]);
        }
        
        quicksort(h, strs, 0, strs.length-1);
        
        for(int i = 1 ; i < strs.length ; i++) {
        	int i2 = i-1;
            while(i2>=0 && h[i] == h[i2]) {
            	if(compare(strs[i], strs[i2])) {
            		if(!contain(intRe, i)) {
            			intRe.add(i);
            			strRe.add(strs[i]);
//            			System.out.println(strs[i]);
            		}
            		if(!contain(intRe, i2)) {
            			intRe.add(i2);
            			strRe.add(strs[i2]);
//            			System.out.println(strs[i2]);
            		}
            	}
            	
            	i2--;
            }
        }
        
        System.out.println(strRe.size());
        return strRe;
    }
    
    public boolean contain(List <Integer> a, int b) {
    	for(int i =0  ; i < a.size(); i++) {
    		if(a.get(i)==b) return true;
    	}
    	return false;
    }
    
    public boolean compare(String a, String b) {
    	if(a.length() != b.length()) return false;
    	
    	int [] map = new int [26];
        for(int i = 0 ; i < a.length() ; i ++) {
            char c = a.charAt(i);
            if(c >= 'a' && c <= 'z') {
                map[c-'a']++;
            }
            c = b.charAt(i);
            if(c >= 'a' && c <= 'z') {
                map[c-'a']--;
            }
        }
        for(int i = 0 ; i < map.length ; i++) {
        	if(map[i] != 0) return false;
        }
        return true;
    }
    
    public static void quicksort(int [] list, String []l2, int start, int end) 
	{
		if(start > end) return;
		int pivot = list[(start + end) / 2];
		int a = start ;
		int b = end ;
		int temp = 0 ;
		
		while(a <= b)
		{
			while(list[a] < pivot)
				a++ ;
			while(list[b] > pivot)
				b-- ;
			if(a <= b)
			{
				temp = list[a] ;
				list[a] = list[b] ;
				list[b] = temp ;
				String t = l2[a];
				l2[a] = l2[b];
				l2[b] = t;
				a++ ;
				b-- ;
			}
		}
		if(start < a-1)
			quicksort(list, l2, start, a-1 ) ;
		if(a < end)
			quicksort(list, l2, a, end ) ;
	}
    
    public int hash(String str) {
        int [] map = new int [26];
        for(int i = 0 ; i < str.length() ; i ++) {
            char c = str.charAt(i);
            if(c >= 'a' && c <= 'z') {
                map[c-'a']++;
            }
        }
        
        int h = 0;
        for(int i = 0 ; i < 26 ; i ++) {
            h = (h * 4 + map[i]) % 54321123;
        }
        return h;
    }
}